package com.artPreter.pojo;



import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.Data;

import java.time.LocalDateTime;

@Data
@TableName("jv_user")
public class User {

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;//主键ID


    @TableField("username")
    private String username;//用户名

    @TableField("password")
    @JsonIgnore//让springmvc把当前对象转换成json字符串的时候,忽略password,最终的json字符串中就没有password这个属性了
    private String password;//密码

    @TableField("nickname")
    private String nickname;//昵称

    @TableField("email")
    private String email;//邮箱

    @TableField("user_pic")
    private String userPic;//用户头像地址

    @TableField("create_time")
    private LocalDateTime createTime;//创建时间

    @TableField("update_time")
    private LocalDateTime updateTime;//更新时间

    //是否允许登录  0:不允许  1:允许
    @TableField("auth_login")
    private Integer authLogin;

    @TableField("uuid")
    private String uuid;

    @TableField("tel")
    private String tel;

    @TableField("phone")
    private String phone;

    @TableField("depart")
    private String depart;

    @TableField("status")
    private Integer status;

    @TableField(exist = false)
    private String[] roles = {"ADMIN"};

    public User() {
    }

    public User(User user, int type) {
        switch (type){
            case 2:
                if(user.getStatus()==0){
                    this.status = 1;
                }else {
                    this.status = 0;
                }
                break;
        }
    }
}
